def is_valid_sequence(b):
    c = []
    for a in b:
        if b in '([{<':
            c.append(b)
        elif b in ')]}>':
            if not stack:
                return False
            if b == ')' and c[-1] == '(':
                c.pop()
            elif b == ']' and c[-1] == '[':
                c.pop()
            elif b == '}' and c[-1] == '{':
                c.pop()
            elif b == '>' and c[-1] == '<':
                c.pop()
            else:
                return False
    return not c


print(is_valid_sequence(input('Введите последовательность скобок:')))
